package leetcode.code011;

/**
 * @author Max
 * @date 2021年9月1日
 * @description
 */
public class Solution extends Solution011 {

	@Override
	public int maxArea(int[] height) {
		int l = 0;
		int r = height.length - 1;
		int max = 0;
		while (l < r) {
			int left = height[l];
			int right = height[r];
			max = Math.max(max, (r - l) * Math.min(left, right));
			if (left < right) {
				while (height[l] <= left && l < r) {
					l++;
				}
			} else {
				while (height[r] <= right && l < r) {
					r--;
				}
			}
		}
		return max;
	}

	public static void main(String[] args) {
		Solution so = new Solution();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();
	}

}
